import { createRequest } from '/@/api/service';
const module = 'ib/base/v1/AlarmApi';

/**
 * @function 查询发送给当前登录用户的告警列表(适用于APP端)
 * @param data
 * @param header
 * @returns {Promise}
 */
function QUERY_ALARM_LIST_BY_USER(
  data: AlarmApi.QueryAlarmListByUserReq,
  header: object = {},
): Promise<AlarmApi.QueryAlarmListByUserResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}/queryAlarmListByUser`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 查看告警详情
 * @param data
 * @param header
 * @returns {Promise}
 */
function QUERY_ALARM_DETAIL(
  data: AlarmApi.QueryAlarmDetailReq,
  header: object = {},
): Promise<AlarmApi.QueryAlarmDetailResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/detail`, data, header, 'POST');
}

/**
 * @function 处理告警
 * @param data
 * @param header
 * @returns {Promise}
 */
function ALARM_DEAL(data: AlarmApi.DealReq, header: object = {}): Promise<AlarmApi.DealResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/deal`, data, header, 'POST');
}

/**
 * @function 阅读告警
 * @param data
 * @param header
 * @returns {Promise}
 */
function ALARM_READ(data: AlarmApi.ReadReq, header: object = {}): Promise<AlarmApi.ReadResp> {
  return createRequest(`${process.env.APP_API_URL}${module}/read`, data, header, 'POST');
}

export { QUERY_ALARM_LIST_BY_USER, QUERY_ALARM_DETAIL, ALARM_DEAL, ALARM_READ };
